package collection;

import java.util.Iterator;
import java.util.NoSuchElementException;

public class IteratorDemo {
    public static void main(String[] args) {
     System.out.println("--------------");
    }
    static abstract class YList<T> implements Iterable<T> {
        T[] ts;

        public YList(T...ts) {
            this.ts=ts;
        }
    }

    static abstract class YIterator<E> implements Iterable<E>, collection.YIterator {
        int index=0;
         E[] ts;
          public YIterator(E[] ts){
              if(null==ts){
                  return;
              }
              this.ts=ts;
          }


        public boolean hasNext() {
            return index<ts.length;
        }


        public E next() throws NoSuchElementException {
              if(index>=ts.length){
                throw new NoSuchElementException();
              }
            return ts[index++];
        }
    }
}
